#!/bin/bash

# 要监控的进程数量
TOTAL_PROCESSES=4

# 日志文件目录
LOG_DIR="/logs"

# 遍历所有的进程编号
for i in $(seq 0 $TOTAL_PROCESSES)
do
    # 检查对应的进程是否在运行
    PROCESS_COUNT=$(ps aux | grep "runChannelInfo.py $i s" | grep -v grep | wc -l)

    if [ $PROCESS_COUNT -eq 0 ]; then
        echo "Process runChannelInfo.py $i is not running. Restarting..."
		source /techbuddy/anaconda3/bin/activate search

        nohup /techbuddy/envs/search/bin/python -u /data/wwwroot/python/jingwai/runChannelInfo.py $i s > ${LOG_DIR}/handelChannel${i}.log 2>&1 &
        echo "Process runChannelInfo.py $i restarted."
    else
        echo "Process runChannelInfo.py $i is running."
    fi
done

